import ajax from './ajax'

export default {

  bestPost(id, onSuccess) {
    ajax.post('/plus/topics/posts/' + id + '/best')
        .then(onSuccess);
  },

  unbestPost(id, onSuccess) {
    ajax.post('/plus/topics/posts/' + id + '/unbest')
        .then(onSuccess);
  },

  topPost(id, onSuccess) {
    ajax.post('/plus/topics/posts/' + id + '/top')
        .then(onSuccess);
  },

  untopPost(id, onSuccess) {
    ajax.post('/plus/topics/posts/' + id + '/untop')
        .then(onSuccess);
  },

  delPost(id, onSuccess) {
    ajax.post('/plus/topics/posts/' + id + '/del')
        .then(onSuccess);
  },

  delComment(id, onSuccess) {
    ajax.post('/plus/topics/comments/' + id + '/del')
        .then(onSuccess);
  },

  loadTickets(query, offset, limit, onSuccess) {
    ajax.get('/plus/topics/posts?offset=' + offset + "&limit=" + limit + "&query=" + query)
        .then(onSuccess);
  },

  loadPosts(query, offset, limit, onSuccess) {
    ajax.get('/plus/topics/posts?type=common&offset=' + offset + "&limit=" + limit + "&query=" + query)
        .then(onSuccess);
  },

  loadComments(offset, limit, onSuccess) {
    ajax.get('/plus/topics/comments?offset=' + offset + "&limit=" + limit)
        .then(onSuccess);
  },

  loadJournals(offset, limit, onSuccess) {
    ajax.get('/plus/journals?offset=' + offset + "&limit=" + limit)
        .then(onSuccess);
  },

  onlineJournal(id, onSuccess) {
    ajax.post('/plus/journals/' + id + '/online')
        .then(onSuccess);
  },

  offlineJournal(id, onSuccess) {
    ajax.post('/plus/journals/' + id + '/offline')
        .then(onSuccess);
  },

};